<?php
class BackLinkEngineAllTheWeb extends LogicBackLinkEngine
{
	/**
	 * @param string $url
	 * @return SeoSiteRank
	 */
	public function process($url)
	{
		$url = urlencode($url);
		$allTheWebUrl = "http://www.alltheweb.com/search?cat=web&cs=utf-8&q=link%3A$url&_sb_lang=any";
		Ezer_Log::debug("Load URL [$allTheWebUrl]");
		$content = file_get_contents($allTheWebUrl);
		
		preg_match_all('/<span class="resURL">([^<]+)<\/span>/imsU', $content, $matches);
		
		if(count($matches) != 2)
			return null;
			
		$links = array();
		foreach($matches[1] as $index => $val)
		{
			$backLink = new SeoSiteBackLink();
			$backLink->setEngineType($this->getType());
			$backLink->setSrcUrl(trim($val));
			$links[] = $backLink;
		}
		Ezer_Log::debug("Found [" . count($links) . "] links");
		return $links;
	}
}